#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char* itoa( int , char , int  );
int main()
{
char a[128];
char b[1024];
int n;
int t;
int i;
while(gets(a)){
n=strlen(a);
t=0;
int e=0;
for(i=2;i<n;i++){
if(a[i]>='a'&&a[i]<='f'){
t=t*16+a[i]-'a'+10;
}
else if(a[i]>='A'&&a[i]<='F'){
t=t*16+a[i]-'A'+10;
}
else if(a[i]>='0'&&a[i]<='9'){
t=t*16+a[i]-'0';
}
else{
printf("error\n");
e=1;
break;
}
}
if(e!=1){
itoa(t,b,10);
printf("%s\n",b);
}
}

return 0;
}
	
char* itoa( int value, char* result, int base ) {
	
	// check that the base if valid
	
	if (base < 2 || base > 16) { *result = 0; return result; }
	

	
	char* out = result;
	
	int quotient = value;
	

	
	do {
	
		*out = "0123456789abcdef"[ std::abs( quotient % base ) ];
	
		++out;
	
		quotient /= base;
	
	} while ( quotient );
	


	
	// Only apply negative sign for base 10
	
	if ( value < 0 && base == 10) *out++ = '-';
	

	
	std::reverse( result, out );
	
	*out = 0;
	
	return result;
	
}
	

	